#include "DoxyBlocksLogger.h"

#include <cbplugin.h>
#include <pluginmanager.h>
#include <prep.h>

#include <wx/sizer.h>


void DoxyBlocksLogger::UpdateSettings() {
  TextCtrlLogger::UpdateSettings();
}

wxWindow* DoxyBlocksLogger::CreateControl( wxWindow* parent ) {
  panel = new wxPanel( parent );
  TextCtrlLogger::CreateControl( panel );
  control->SetId( ID_LOG_DOXYBLOCKS );
  sizer = new wxBoxSizer( wxVERTICAL );
  sizer->Add( control, 1, wxEXPAND, 0 );
  panel->SetSizer( sizer );
  return panel;
}

void DoxyBlocksLogger::OpenLink( long urlStart, long urlEnd, bool bUseInternalViewer ) {
  if( !control ) {
    return;
  }
  wxString url = control->GetRange( urlStart, urlEnd );
  if( bUseInternalViewer ) {
    cbMimePlugin* p = Manager::Get()->GetPluginManager()->GetMIMEHandlerForFile( url );
    p->OpenFile( url );
  } else {
    wxLaunchDefaultBrowser( url );
  }
}
